﻿using System;
using System.Net;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities
{
    public class Defenses
    {
        #region Fields
        private Armor ArmorField;
        private Defense _defenseField;
        private Dodge _dodgeField;
        private Parry _parryField;
        private Block _blockField;
        private Resilience _resilienceField;
        #endregion
        #region Properties
        public Armor Armor
        {
            get
            {
                return this.ArmorField;
            }
            set
            {
                this.ArmorField = value;
            }
        }

        public Defense Defense
        {
            get
            {
                return this._defenseField;
            }
            set
            {
                this._defenseField = value;
            }
        }

        public Dodge Dodge
        {
            get
            {
                return this._dodgeField;
            }
            set
            {
                this._dodgeField = value;
            }
        }

        public Parry Parry
        {
            get
            {
                return this._parryField;
            }
            set
            {
                this._parryField = value;
            }
        }

        public Block Block
        {
            get
            {
                return this._blockField;
            }
            set
            {
                this._blockField = value;
            }
        }

        public Resilience Resilience
        {
            get
            {
                return this._resilienceField;
            }
            set
            {
                this._resilienceField = value;
            }
        }
        #endregion
        #region Constructor
        public Defenses(XElement element)
        {
            Armor = element.Elements("armor").Select(e => new Armor(e)).FirstOrDefault();
            Defense = element.Elements("defense").Select(e => new Defense(e)).FirstOrDefault();
            Dodge = element.Elements("dodge").Select(e => new Dodge(e)).FirstOrDefault();
            Parry = element.Elements("parry").Select(e => new Parry(e)).FirstOrDefault();
            Block = element.Elements("block").Select(e => new Block(e)).FirstOrDefault();
            Resilience = element.Elements("resilience").Select(e => new Resilience(e)).FirstOrDefault();
        }
        #endregion
    }
}
